/*
 * Middleware
 * Copyright (C) 2010/11
 * Riccardo Pulvirenti, Giuseppe Ravidà, Andrea Tino
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANDABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses
 */

/*!
 * File: performance_index_test.hpp
 */

#ifndef _PERFORMANCE_INDEX_TEST_HPP_
#define _PERFORMANCE_INDEX_TEST_HPP_

#define SHOW_SINGLE_FUNCTS

#include <iostream>
#include <sstream>
#include "performance_index.hpp"

using namespace std;
using namespace middleware::calculus;

//-----------------------------------------------------------------------------
// Definitions + implementations
namespace middleware {
namespace calculus {
void CalculatePITest();
//-----------------------------------------------------------------------------
// Implementations
void CalculatePITest() {
	PerformanceEvalParams pc1;
	PerformanceEvalParams pc2;
	PerformanceEvalParams pc3;
	PerformanceEvalParams pc4;
	PerformanceEvalParams pc5;
	PerformanceEvalParams pc6;
	PerformanceEvalParams pc7;
	PerformanceEvalParams pc8;
	PerformanceEvalParams pc9;
	PerformanceEvalParams pc10;
	PerformanceEvalParams pc11;
	PerformanceEvalParams pc12;
	PerformanceEvalParams pc13;
	PerformanceEvalParams pc14;
	PerformanceEvalParams pc15;
	PIType pi1;
	PIType pi2;
	PIType pi3;
	PIType pi4;
	PIType pi5;
	PIType pi6;
	PIType pi7;
	PIType pi8;
	PIType pi9;
	PIType pi10;
	PIType pi11;
	PIType pi12;
	PIType pi13;
	PIType pi14;
	PIType pi15;
	/*!
	 * Setup PC1
	 */
	pc1.eval_cpu_mhz = 600; /* z --> CPU MHz */
	pc1.eval_ram_mb = 256; /* m --> RAM in MegaBytes */
	pc1.eval_core_num = 1; /* c --> Number of cores per processor */
	pc1.eval_cpu_num = 1; /* p --> Number of processors */
	pc1.eval_hops = 5; /* D --> INET hop distance */
	pc1.eval_bandwidth = 2000.0; /* B --> Bandwidth in KBit/s */
	pc1.eval_load = 5; /* L --> Number of tasks in queue in worker */
	pi1 = CalculatePI(pc1);
	/*!
	 * Setup PC2
	 */
	pc2.eval_cpu_mhz = 1200.0; /* z --> CPU MHz */
	pc2.eval_ram_mb = 4096.0; /* m --> RAM in MegaBytes */
	pc2.eval_core_num = 4; /* c --> Number of cores per processor */
	pc2.eval_cpu_num = 2; /* p --> Number of processors */
	pc2.eval_hops = 5; /* D --> INET hop distance */
	pc2.eval_bandwidth = 4000.0; /* B --> Bandwidth in KBit/s */
	pc2.eval_load = 25; /* L --> Number of tasks in queue in worker */
	pi2 = CalculatePI(pc2);
	/*!
	 * Setup PC3
	 */
	pc3.eval_cpu_mhz = 900.0; /* z --> CPU MHz */
	pc3.eval_ram_mb = 2048.0; /* m --> RAM in MegaBytes */
	pc3.eval_core_num = 2; /* c --> Number of cores per processor */
	pc3.eval_cpu_num = 2; /* p --> Number of processors */
	pc3.eval_hops = 5; /* D --> INET hop distance */
	pc3.eval_bandwidth = 4000.0; /* B --> Bandwidth in KBit/s */
	pc3.eval_load = 15; /* L --> Number of tasks in queue in worker */
	pi3 = CalculatePI(pc3);
	/*!
	 * Setup PC4
	 */
	pc4.eval_cpu_mhz = 600; /* z --> CPU MHz */
	pc4.eval_ram_mb = 256.0; /* m --> RAM in MegaBytes */
	pc4.eval_core_num = 1; /* c --> Number of cores per processor */
	pc4.eval_cpu_num = 1; /* p --> Number of processors */
	pc4.eval_hops = 5; /* D --> INET hop distance */
	pc4.eval_bandwidth = 2000.0; /* B --> Bandwidth in KBit/s */
	pc4.eval_load = 25; /* L --> Number of tasks in queue in worker */
	pi4 = CalculatePI(pc4);
	/*!
	 * Setup PC5
	 */
	pc5.eval_cpu_mhz = 800; /* z --> CPU MHz */
	pc5.eval_ram_mb = 4096.0; /* m --> RAM in MegaBytes */
	pc5.eval_core_num = 8; /* c --> Number of cores per processor */
	pc5.eval_cpu_num = 4; /* p --> Number of processors */
	pc5.eval_hops = 30; /* D --> INET hop distance */
	pc5.eval_bandwidth = 20000.0; /* B --> Bandwidth in KBit/s */
	pc5.eval_load = 15; /* L --> Number of tasks in queue in worker */
	pi5 = CalculatePI(pc5);
	/*!
	 * Setup PC6
	 */
	pc6.eval_cpu_mhz = 1200; /* z --> CPU MHz */
	pc6.eval_ram_mb = 2048; /* m --> RAM in MegaBytes */
	pc6.eval_core_num = 2; /* c --> Number of cores per processor */
	pc6.eval_cpu_num = 2; /* p --> Number of processors */
	pc6.eval_hops = 35; /* D --> INET hop distance */
	pc6.eval_bandwidth = 56.0; /* B --> Bandwidth in KBit/s */
	pc6.eval_load = 8; /* L --> Number of tasks in queue in worker */
	pi6 = CalculatePI(pc6);
	/*!
	 * Setup PC7
	 */
	pc7.eval_cpu_mhz = 2400; /* z --> CPU MHz */
	pc7.eval_ram_mb = 4096.0; /* m --> RAM in MegaBytes */
	pc7.eval_core_num = 4; /* c --> Number of cores per processor */
	pc7.eval_cpu_num = 2; /* p --> Number of processors */
	pc7.eval_hops = 40; /* D --> INET hop distance */
	pc7.eval_bandwidth = 4000.0; /* B --> Bandwidth in KBit/s */
	pc7.eval_load = 20; /* L --> Number of tasks in queue in worker */
	pi7 = CalculatePI(pc7);
	/*!
	 * Setup PC8
	 */
	pc8.eval_cpu_mhz = 800; /* z --> CPU MHz */
	pc8.eval_ram_mb = 1024.0; /* m --> RAM in MegaBytes */
	pc8.eval_core_num = 1; /* c --> Number of cores per processor */
	pc8.eval_cpu_num = 1; /* p --> Number of processors */
	pc8.eval_hops = 40; /* D --> INET hop distance */
	pc8.eval_bandwidth = 4000.0; /* B --> Bandwidth in KBit/s */
	pc8.eval_load = 5; /* L --> Number of tasks in queue in worker */
	pi8 = CalculatePI(pc8);
	/*!
	 * Setup PC9
	 */
	pc9.eval_cpu_mhz = 2400; /* z --> CPU MHz */
	pc9.eval_ram_mb = 2048.0; /* m --> RAM in MegaBytes */
	pc9.eval_core_num = 2; /* c --> Number of cores per processor */
	pc9.eval_cpu_num = 2; /* p --> Number of processors */
	pc9.eval_hops = 30; /* D --> INET hop distance */
	pc9.eval_bandwidth = 1000.0; /* B --> Bandwidth in KBit/s */
	pc9.eval_load = 10; /* L --> Number of tasks in queue in worker */
	pi9 = CalculatePI(pc9);
	/*!
	 * Setup PC10
	 */
	pc10.eval_cpu_mhz = 900; /* z --> CPU MHz */
	pc10.eval_ram_mb = 8192.0; /* m --> RAM in MegaBytes */
	pc10.eval_core_num = 8; /* c --> Number of cores per processor */
	pc10.eval_cpu_num = 4; /* p --> Number of processors */
	pc10.eval_hops = 5; /* D --> INET hop distance */
	pc10.eval_bandwidth = 20000.0; /* B --> Bandwidth in KBit/s */
	pc10.eval_load = 25; /* L --> Number of tasks in queue in worker */
	pi10 = CalculatePI(pc10);
	/*!
	 * Setup PC11
	 */
	pc11.eval_cpu_mhz = 2400; /* z --> CPU MHz */
	pc11.eval_ram_mb = 8192.0; /* m --> RAM in MegaBytes */
	pc11.eval_core_num = 4; /* c --> Number of cores per processor */
	pc11.eval_cpu_num = 2; /* p --> Number of processors */
	pc11.eval_hops = 35; /* D --> INET hop distance */
	pc11.eval_bandwidth = 1000.0; /* B --> Bandwidth in KBit/s */
	pc11.eval_load = 7; /* L --> Number of tasks in queue in worker */
	pi11 = CalculatePI(pc11);
	/*!
	 * Setup PC12
	 */
	pc12.eval_cpu_mhz = 1200; /* z --> CPU MHz */
	pc12.eval_ram_mb = 512.0; /* m --> RAM in MegaBytes */
	pc12.eval_core_num = 1; /* c --> Number of cores per processor */
	pc12.eval_cpu_num = 1; /* p --> Number of processors */
	pc12.eval_hops = 5; /* D --> INET hop distance */
	pc12.eval_bandwidth = 2000.0; /* B --> Bandwidth in KBit/s */
	pc12.eval_load = 18; /* L --> Number of tasks in queue in worker */
	pi12 = CalculatePI(pc12);
	/*!
	 * Setup PC13
	 */
	pc13.eval_cpu_mhz = 2400; /* z --> CPU MHz */
	pc13.eval_ram_mb = 2048.0; /* m --> RAM in MegaBytes */
	pc13.eval_core_num = 2; /* c --> Number of cores per processor */
	pc13.eval_cpu_num = 2; /* p --> Number of processors */
	pc13.eval_hops = 30; /* D --> INET hop distance */
	pc13.eval_bandwidth = 20000.0; /* B --> Bandwidth in KBit/s */
	pc13.eval_load = 22; /* L --> Number of tasks in queue in worker */
	pi13 = CalculatePI(pc13);
	/*!
	 * Setup PC14
	 */
	pc14.eval_cpu_mhz = 600; /* z --> CPU MHz */
	pc14.eval_ram_mb = 512.0; /* m --> RAM in MegaBytes */
	pc14.eval_core_num = 1; /* c --> Number of cores per processor */
	pc14.eval_cpu_num = 1; /* p --> Number of processors */
	pc14.eval_hops = 40; /* D --> INET hop distance */
	pc14.eval_bandwidth = 2000.0; /* B --> Bandwidth in KBit/s */
	pc14.eval_load = 6; /* L --> Number of tasks in queue in worker */
	pi14 = CalculatePI(pc14);
	/*!
	 * Setup PC15
	 */
	pc15.eval_cpu_mhz = 2400; /* z --> CPU MHz */
	pc15.eval_ram_mb = 2048.0; /* m --> RAM in MegaBytes */
	pc15.eval_core_num = 4; /* c --> Number of cores per processor */
	pc15.eval_cpu_num = 4; /* p --> Number of processors */
	pc15.eval_hops = 35; /* D --> INET hop distance */
	pc15.eval_bandwidth = 10000.0; /* B --> Bandwidth in KBit/s */
	pc15.eval_load = 20; /* L --> Number of tasks in queue in worker */
	pi15 = CalculatePI(pc15);
	/* Final results */
	cout << "PI PC1: " << pi1 << endl;
	cout << "PI PC2: " << pi2 << endl;
	cout << "PI PC3: " << pi3 << endl;
	cout << "PI PC4: " << pi4 << endl;
	cout << "PI PC5: " << pi5 << endl;
	cout << "PI PC6: " << pi6 << endl;
	cout << "PI PC7: " << pi7 << endl;
	cout << "PI PC8: " << pi8 << endl;
	cout << "PI PC9: " << pi9 << endl;
	cout << "PI PC10: " << pi10 << endl;
	cout << "PI PC11: " << pi11 << endl;
	cout << "PI PC12: " << pi12 << endl;
	cout << "PI PC13: " << pi13 << endl;
	cout << "PI PC14: " << pi14 << endl;
	cout << "PI PC15: " << pi15 << endl;
#ifdef SHOW_SINGLE_FUNCTS
	/*!
	 * Testing Log Function
	 */
	double logarithm;
	logarithm = Log(8.2,1270.0);
	cout << "Log(8.2, 1270)= " << logarithm << endl;
	/*!
	 * Testing Sqrt Function
	 */
	double radix;
	radix = Sqrt(1040);
	cout << "Sqrt(1040)= " << radix << endl;
	/*!
	 * Testing Exp Function
	 */
	double power;
	power = Exp(2.2,0.1);
	cout << "2.2^0.1= " << power << endl;
#endif
}
} /* middleware */
} /* calculus */
#endif
